package com.zaydanwu.cla.controller.students;

import com.zaydanwu.cla.model.Comment;
import com.zaydanwu.cla.model.result.ApiResult;
import com.zaydanwu.cla.model.result.CommentResult;
import com.zaydanwu.cla.service.CommentService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @BelongsProject: cla
 * @BelongsPackage: com.zaydanwu.cla.controller.students
 * @Author: zaydanwu
 * @CreateTime: 2019-01-05 13:14
 * @Description:
 */
@RestController
@RequestMapping("/cla/api")
public class CommentController {

    @Resource
    private CommentService commentService;

    @RequestMapping("/saveComment")
    public ApiResult<Object> saveComment(@RequestBody Comment record) {
        int i = commentService.saveComment(record);
        return ApiResult.success(i);
    }

    @RequestMapping("/getAllComment")
    public ApiResult<CommentResult> getAllComment(@RequestParam Integer newId) {
        CommentResult allComment = commentService.getAllComment(newId);
        return ApiResult.success(allComment);
    }
}
